<?php
/**
 * Created by PhpStorm.
 * User: wodrow
 * Date: 18-2-28
 * Time: 下午4:45
 */

namespace common\components\proxy_payment;


use common\models\ProxyPay;
use common\models\ProxyPayBack;
use yii\base\Component;
use yii\base\ErrorException;

abstract class ProxyPayment extends Component
{
    /**
     * @var ProxyPay $pay_model
     */
    public $pay_model;
    /**
     * @var
     */
    public $recive_model;
    /**
     * @var ProxyPayBack $pay_back_model
     */
    public $pay_back_model;

    protected $_return;

    /*protected $_return = [
        'ret_code' => '000000',
        'ret_msg' => '成功',
        'ret_desc' => 'acceptSuccess',
    ];*/

    /**
     * @param $company_code
     * @return Api $plat_form
     * @throws ErrorException
     */
    public static function getPlatForm($company_code)
    {
        switch ($company_code) {
            case Fuiou::COMPANY_CODE:
                $plat_form = new Fuiou();
                break;
            case Fuiou1::COMPANY_CODE:
                $plat_form = new Fuiou1();
                break;
            default:
                throw new ErrorException("没有找到代收付公司");
                break;
        }
        return $plat_form;
    }

    protected function _checkPayModel()
    {
        if (!$this->pay_model){
            throw new ErrorException("没有找到代付模型");
        }
    }
}